package com.hqyj.controller;

import com.hqyj.pojo.UserPower;
import com.hqyj.service.UserPowerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Map;

/**
 * Created with Intellij IDEA.
 * User:LiTao
 * Date:2022/8/30
 * Time:14:12
 * Description:
 */
@Controller
@RequestMapping("/power")
public class UserPowerController {

    @Autowired
    private UserPowerService userPowerService;


    // 全查，分页，模糊
    @RequestMapping("/selectAll")
    @ResponseBody
    public Map<String,Object> selectAll(int pageNum,int pageSize,String remark){
        return userPowerService.selectAll(pageNum, pageSize,remark);
    }

    // 添加用户
    @RequestMapping("/add")
    @ResponseBody
    public Map<String,Object> add(String power,String remark){
        return userPowerService.add(power,remark);
    }

    // 回显
    @RequestMapping("/update")
    @ResponseBody
    public Map<String,Object> update(int id){
        return userPowerService.update(id);
    }

    //修改用户
    @RequestMapping("/updateUser")
    @ResponseBody
    public Map<String,Object> updateUser(UserPower userPower){
        return userPowerService.updateUser(userPower);
    }

    //删除用户
    @RequestMapping("/deleteUser")
    @ResponseBody
    public Map<String,Object> deleteUser(int id){
        return userPowerService.deleteUser(id);
    }


    @ResponseBody
    @RequestMapping("/getAll")
    public Map<String,Object> getAllPower(){
        return userPowerService.getAllPower();
    }
}
